#!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
@Project ：employment_class 
@File    ：02_Msql_Helper.py
@IDE     ：PyCharm 
@Author  ：小邓的烂笔头
@Date    ：2021/10/17 下午4:30 
"""

from pymysql import *

class MySqlHelper(object):
    def __init__(self):
        self.connect = connect(
            host='localhost',
            port=3306,
            user='root',
            password='123456',
            db='base'
        )
        self.cursorl = self.connect.cursor()

    def close(self):
        self.cursorl.close()
        self.connect.close()

    def cud(self,sql,params):
        try:
            self.cursorl.execute(sql,params)
            result = self.cursorl.fetchall()
            self.connect.commit()
            return result
        except Exception as e:
            print(e)
        finally:
            self.close()
